package jasongarrett.spida;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class ApplicationJSONConverter
{
	public static String jsonFromApplication(Application application) throws JsonProcessingException
	{
		ObjectMapper mapper = new ObjectMapper();
		String json = mapper.writeValueAsString(application);
		return json;
	}
	
	public static Application applicationFromJson(String json) 
			throws JsonParseException, JsonMappingException, IOException
	{
		Application application;
		ObjectMapper mapper = new ObjectMapper();
		application = mapper.readValue(json, Application.class);
		return application;
	}
}
